package com.study.spring.kafka;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration;
import org.springframework.kafka.annotation.KafkaHandler;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * @author
 * @date 2022年05月03日 12:49
 * @description
 */
@Component
@Slf4j
@KafkaListener(topics = {"first-topic"},groupId = "test-consumer-group")
@ConditionalOnBean(KafkaAutoConfiguration.class)
public class Consumer {

    @KafkaHandler
    public void receive(String message){

        log.info("我是消费者，我接收到的消息是："+message);
    }
}
